/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bsc.war.populate;

import bsc.ejb.entity.*;
import bsc.ejb.entity.ScoreCardDimension;
import bsc.ejb.metadata.Colorimetry;
import bsc.ejb.metadata.Comparation;
import bsc.ejb.metadata.Framework;
import bsc.ejb.metadata.MapDrawing;
import bsc.ejb.metadata.Unit;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import bsc.war.service.ScoreCardUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 *
 * @author luisZavaleta
 */
public class NectaresPopulate extends AbstractController {

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");


        //Se crea un FrameWork
        try {

            createFramework(request, response, delegate);
        } catch (Exception e) {
            e.printStackTrace();
        }


            return new ModelAndView("advancePopulate");
    }

    public static void createFramework(HttpServletRequest request,
            HttpServletResponse response, DelegateBSC delegate) {

        //Create a Framework
        Framework framework = (Framework) Factory.getBean("Framework");
        framework.setName("Néctares del Sureste");
        framework.setDescription("Framework de Trabajo para Néctares del Surests");
        framework.setActive(Boolean.TRUE);

        delegate.createFramework(framework);

        //Create a Colorimetries
        //Green
        Colorimetry colorimetryGreen = (Colorimetry) Factory.getBean("Colorimetry");
        colorimetryGreen.setName("Green");
        colorimetryGreen.setPriority(1);
        colorimetryGreen.setFramework(framework);
        colorimetryGreen.setColor("00FF00");
        delegate.createColorimetry(colorimetryGreen);

        //Yellow
        Colorimetry colorimetryYellow = (Colorimetry) Factory.getBean("Colorimetry");
        colorimetryYellow.setName("Yellow");
        colorimetryYellow.setPriority(2);
        colorimetryYellow.setFramework(framework);
        colorimetryYellow.setColor("FFFF00");
        delegate.createColorimetry(colorimetryYellow);

        //Red
        Colorimetry colorimetryRed = (Colorimetry) Factory.getBean("Colorimetry");
        colorimetryRed.setName("Red");
        colorimetryRed.setPriority(3);
        colorimetryRed.setFramework(framework);
        colorimetryRed.setColor("FF0000");
        delegate.createColorimetry(colorimetryRed);

        //Create Map Drawing
        MapDrawing mapDrawing = (MapDrawing) Factory.getBean("MapDrawing");
        mapDrawing.setName("Dibujo del Mapa de Néctares del Sureste");
        mapDrawing.setDescription(METHOD_GET);
        mapDrawing.setFile("/files/bsc/map/MapaNectares.jpg");
        mapDrawing.setFramework(framework);
        delegate.createMapDrawing(mapDrawing);

        //Create Comparation
        Comparation comparationReal = (Comparation) Factory.getBean("Comparation");
        comparationReal.setName("Real");
        comparationReal.setType(Comparation.Type.REAL);
        comparationReal.setFramework(framework);

        Comparation comparationGoal = (Comparation) Factory.getBean("Comparation");
        comparationGoal.setName("Meta");
        comparationGoal.setType(Comparation.Type.GOAL);
        comparationGoal.setFramework(framework);

        delegate.createComparation(comparationReal);
        delegate.createComparation(comparationGoal);

        Unit unitPesos = (Unit) Factory.getBean("Unit");
        unitPesos.setName("$");
        unitPesos.setDescription("Pesos");
        unitPesos.setFramework(framework);
        delegate.createUnit(unitPesos);
        
        Unit unitPorcentaje = (Unit) Factory.getBean("Unit");
        unitPorcentaje.setName("%");
        unitPorcentaje.setDescription("Porcentaje");
        unitPorcentaje.setFramework(framework);
        delegate.createUnit(unitPorcentaje);

        //Se inicia la creación del MODELO

        //DIMENSIONES
        //DIMENSION TOTAL
        //Populate a new Dimension
        Dimension dimensionNormal = (Dimension) Factory.getBean("Dimension");
        dimensionNormal.setName("SIN_DIMENSION");
        delegate.createDimension(dimensionNormal);

        //Populate a new Member
        DimensionMember dimensionmember1Normal = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember1Normal.setName("TOTAL");
        dimensionmember1Normal.setDimension(dimensionNormal);
        delegate.createDimensionMember(dimensionmember1Normal);


        //DIMENSION PRODUCTOS
        //Populate a new Dimension
        Dimension dimensionProductos = (Dimension) Factory.getBean("Dimension");
        dimensionProductos.setName("PRODUCTOS");
        delegate.createDimension(dimensionProductos);

        //Populate a new Member
        DimensionMember dimensionmember1Productos = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember1Productos.setName("TOTAL_PRODUCTOS");
        dimensionmember1Productos.setDimension(dimensionProductos);
        delegate.createDimensionMember(dimensionmember1Productos);

        DimensionMember dimensionmember2Productos = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember2Productos.setName("Cien_Néctar");
        dimensionmember2Productos.setDimension(dimensionProductos);
        dimensionmember2Productos.setDimensionMember(dimensionmember1Productos);
        delegate.createDimensionMember(dimensionmember2Productos);

        DimensionMember dimensionmember3Productos = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember3Productos.setName("Néctar_Cero");
        dimensionmember3Productos.setDimension(dimensionProductos);
        dimensionmember3Productos.setDimensionMember(dimensionmember1Productos);
        delegate.createDimensionMember(dimensionmember3Productos);

        DimensionMember dimensionmember4Productos = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember4Productos.setName("Nectarín");
        dimensionmember4Productos.setDimension(dimensionProductos);
        dimensionmember4Productos.setDimensionMember(dimensionmember1Productos);
        delegate.createDimensionMember(dimensionmember4Productos);


        //DIMENSION SISTEMAS
        //Populate a new Dimension
        Dimension dimensionSistemas = (Dimension) Factory.getBean("Dimension");
        dimensionSistemas.setName("SISTEMAS_INFORMACIÓN");
        delegate.createDimension(dimensionSistemas);

        //Populate a new Member
        DimensionMember dimensionmember1Sistemas = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember1Sistemas.setName("TOTAL_SISTEMAS_INFORMACIÓN");
        dimensionmember1Sistemas.setDimension(dimensionSistemas);
        delegate.createDimensionMember(dimensionmember1Sistemas);

        DimensionMember dimensionmember2Sistemas = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember2Sistemas.setName("ERP");
        dimensionmember2Sistemas.setDimension(dimensionSistemas);
        dimensionmember2Sistemas.setDimensionMember(dimensionmember1Sistemas);
        delegate.createDimensionMember(dimensionmember2Sistemas);

        DimensionMember dimensionmember3Sistemas = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember3Sistemas.setName("CRM");
        dimensionmember3Sistemas.setDimension(dimensionSistemas);
        dimensionmember3Sistemas.setDimensionMember(dimensionmember1Sistemas);
        delegate.createDimensionMember(dimensionmember3Sistemas);

        DimensionMember dimensionmember4Sistemas = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember4Sistemas.setName("CONTROL_DE_PISO");
        dimensionmember4Sistemas.setDimension(dimensionSistemas);
        dimensionmember4Sistemas.setDimensionMember(dimensionmember1Sistemas);
        delegate.createDimensionMember(dimensionmember4Sistemas);


        //DIMENSION REGIONES
        //Populate a new Dimension
        Dimension dimensionRegiones = (Dimension) Factory.getBean("Dimension");
        dimensionRegiones.setName("REGIONES");
        delegate.createDimension(dimensionRegiones);

        //Populate a new Member
        DimensionMember dimensionmember1Regiones = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember1Regiones.setName("TOTAL_REGIONES");
        dimensionmember1Regiones.setDimension(dimensionRegiones);
        delegate.createDimensionMember(dimensionmember1Regiones);

        DimensionMember dimensionmember2Regiones = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember2Regiones.setName("Golfo");
        dimensionmember2Regiones.setDimension(dimensionRegiones);
        dimensionmember2Regiones.setDimensionMember(dimensionmember1Regiones);
        delegate.createDimensionMember(dimensionmember2Regiones);

        DimensionMember dimensionmember3Regiones = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember3Regiones.setName("Península");
        dimensionmember3Regiones.setDimension(dimensionRegiones);
        dimensionmember3Regiones.setDimensionMember(dimensionmember1Regiones);
        delegate.createDimensionMember(dimensionmember3Regiones);

        DimensionMember dimensionmember4Regiones = (DimensionMember) Factory.getBean("DimensionMember");
        dimensionmember4Regiones.setName("Pacífico_Sur");
        dimensionmember4Regiones.setDimension(dimensionRegiones);
        dimensionmember4Regiones.setDimensionMember(dimensionmember1Regiones);
        delegate.createDimensionMember(dimensionmember4Regiones);




        //INDICADORES
        //---------------------------INDICADOR F3.1--------------------------------------------------------------------------------------
        //Populate a new KPI
        Pointer pointerF3_1 = (Pointer) Factory.getBean("Pointer");
        pointerF3_1.setName("F3.1 Ventas Netas");
        pointerF3_1.setDescription("Mide el número de Ventas totales que genera Néctares del Sureste al final de cada mes.");
        pointerF3_1.setResponsable("Eduardo Romero");
        pointerF3_1.setUnit("($000,000)");
        delegate.createPointer(pointerF3_1);

        //Populate a new IndDim
        ScoreCardDimension scorecarddimensionF3_1 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionF3_1.setScoreCard(pointerF3_1);
        scorecarddimensionF3_1.setDimension(dimensionRegiones);
        delegate.createScoreCardDimension(scorecarddimensionF3_1);

        //Populate a new Comparador Real
        Comparator comparatorRF3_1 = (Comparator) Factory.getBean("Comparator");
        comparatorRF3_1.setDescription("Real");
        comparatorRF3_1.setComparation(comparationReal);
        comparatorRF3_1.setPointer(pointerF3_1);
        delegate.createComparator(comparatorRF3_1);

        //Populate a new Comparador Meta
        Comparator comparatorMF3_1 = (Comparator) Factory.getBean("Comparator");
        comparatorMF3_1.setDescription("Meta");
        comparatorMF3_1.setComparation(comparationGoal);
        comparatorMF3_1.setPointer(pointerF3_1);
        delegate.createComparator(comparatorMF3_1);

        //Settings
        //Find the scorecard and dimensionalCut

        Comparator comparatorF3_1 = delegate.findComparator(pointerF3_1, comparationReal);
        Long idComparatorF3_1 = comparatorF3_1.getIdComparator();

        //Create setting to that pointer
        Settings settingF3_1 = (Settings) Factory.getBean("Settings");
        settingF3_1.setType(Settings.Type.SCORECARD);
        settingF3_1.setTemporality(Settings.Temporality.LAST);
        settingF3_1.setFrecuency(Settings.Frecuency.MONTHLY);
        settingF3_1.setMathOperation("C" + idComparatorF3_1 + "/P");
        settingF3_1.setPolarity(Settings.Polarity.HIGH);
        settingF3_1.setScoreCard(pointerF3_1);
        delegate.createSettings(settingF3_1);

        pointerF3_1.setSettings(settingF3_1);
        delegate.updatePointer(pointerF3_1);


        //Settings de los comparators

        List<Comparator> comparatorsF3_1 = delegate.findComparator(pointerF3_1);
        for (Comparator comparator1 : comparatorsF3_1) {
            Settings settingComparator = (Settings) Factory.getBean("Settings");
            settingComparator.setType(Settings.Type.COMPARATOR);
            settingComparator.setCommand(Settings.Command.SUM);
            settingComparator.setComparator(comparator1);
            delegate.createSettings(settingComparator);

            comparator1.setSettings(settingComparator);
            delegate.updateComparator(comparator1);
        }



        //Populate DimensionalCut
        DimensionalCut dimensionalcut1F3_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1F3_1.setPointer(pointerF3_1);
        dimensionalcut1F3_1.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1F3_1);

        DimensionalCut dimensionalcut2F3_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut2F3_1.setPointer(pointerF3_1);
        dimensionalcut2F3_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut2F3_1);

        DimensionalCut dimensionalcut3F3_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut3F3_1.setPointer(pointerF3_1);
        dimensionalcut3F3_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut3F3_1);

        DimensionalCut dimensionalcut4F3_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut4F3_1.setPointer(pointerF3_1);
        dimensionalcut4F3_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut4F3_1);

        //Se crea la lista de cortes del indicador
        List<DimensionalCut> dimensionalCutsF3_1 = new ArrayList<DimensionalCut>();
        dimensionalCutsF3_1.add(dimensionalcut1F3_1);
        dimensionalCutsF3_1.add(dimensionalcut2F3_1);
        dimensionalCutsF3_1.add(dimensionalcut3F3_1);
        dimensionalCutsF3_1.add(dimensionalcut4F3_1);


        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm1F3_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm1F3_1.setDimensionMember(dimensionmember1Regiones);
        dcm1F3_1.setDimensionalCut(dimensionalcut1F3_1);
        delegate.createDimensionalCutMember(dcm1F3_1);

        DimensionalCutMember dcm2F3_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm2F3_1.setDimensionMember(dimensionmember2Regiones);
        dcm2F3_1.setDimensionalCut(dimensionalcut2F3_1);
        delegate.createDimensionalCutMember(dcm2F3_1);

        DimensionalCutMember dcm3F3_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm3F3_1.setDimensionMember(dimensionmember3Regiones);
        dcm3F3_1.setDimensionalCut(dimensionalcut3F3_1);
        delegate.createDimensionalCutMember(dcm3F3_1);

        DimensionalCutMember dcm4F3_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm4F3_1.setDimensionMember(dimensionmember4Regiones);
        dcm4F3_1.setDimensionalCut(dimensionalcut4F3_1);
        delegate.createDimensionalCutMember(dcm4F3_1);

        //Se METEN LOS DATOS AL INDICADOR
        //SE CREAN las matrices de datos
        Double realValuesF3_1[][] = {{133.0D, 59.0D, 39.0D, 35.0D},
            {124.0D, 62.0D, 39.0D, 23.0D},
            {112.0D, 60.0D, 32.0D, 20.0D},
            {120.0D, 56.0D, 34.0D, 30.0D},
            {129.0D, 61.0D, 39.0D, 29.0D},
            {110.0D, 56.0D, 30.0D, 24.0D}
        };

        Double metaValuesF3_1[][] = {{125.0D, 65.0D, 35.0D, 25.0D},
            {140.0D, 70.0D, 40.0D, 30.0D},
            {140.0D, 70.0D, 40.0D, 30.0D},
            {140.0D, 70.0D, 40.0D, 30.0D},
            {160.0D, 75.0D, 45.0D, 40.0D},
            {160.0D, 75.0D, 45.0D, 40.0D}
        };
        //Se crean las FECHAS
        List<Date> datesF3_1 = ScoreCardUtils.generateDatesRange(ScoreCardUtils.generateDate(1, 1, 2011), ScoreCardUtils.generateDate(1, 6, 2011), pointerF3_1);
        

        for (int i = 0; i < datesF3_1.size(); i++) {
            for (int j = 0; j < dimensionalCutsF3_1.size(); j++) {

                //Valor Real
                ComparatorDimensionalCut cdcRealF3_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcRealF3_1.setComparator(comparatorRF3_1);
                cdcRealF3_1.setDimensionalCut(dimensionalCutsF3_1.get(j));
                cdcRealF3_1.setRegisterDate(datesF3_1.get(i));
                cdcRealF3_1.setRegister(realValuesF3_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcRealF3_1);

                //Valor Meta
                ComparatorDimensionalCut cdcMetaF3_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcMetaF3_1.setComparator(comparatorMF3_1);
                cdcMetaF3_1.setDimensionalCut(dimensionalCutsF3_1.get(j));
                cdcMetaF3_1.setRegisterDate(datesF3_1.get(i));
                cdcMetaF3_1.setRegister(metaValuesF3_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcMetaF3_1);

            }
        }
        //INDICADORES
        //---------------------------FIN INDICADOR F3.1--------------------------------------------------------------------------------------


        //INDICADORES
        //---------------------------INDICADOR F3.2--------------------------------------------------------------------------------------
        //Populate a new KPI
        Pointer pointerF3_2 = (Pointer) Factory.getBean("Pointer");
        pointerF3_2.setName("F3.2. Índice de deserción");
        pointerF3_2.setDescription("Mide el número de Ventas totales que genera Néctares del Sureste al final de cada mes.");
        pointerF3_2.setResponsable("Jorge Naya");
        pointerF3_2.setUnit("(%)");
        delegate.createPointer(pointerF3_2);

        //Populate a new IndDim
        ScoreCardDimension scorecarddimensionF3_2 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionF3_2.setScoreCard(pointerF3_2);
        scorecarddimensionF3_2.setDimension(dimensionRegiones);
        delegate.createScoreCardDimension(scorecarddimensionF3_2);

        //Populate a new Comparador Real
        Comparator comparatorRF3_2 = (Comparator) Factory.getBean("Comparator");
        comparatorRF3_2.setDescription("Real");
        comparatorRF3_2.setComparation(comparationReal);
        comparatorRF3_2.setPointer(pointerF3_2);
        delegate.createComparator(comparatorRF3_2);

        //Populate a new Comparador Meta
        Comparator comparatorMF3_2 = (Comparator) Factory.getBean("Comparator");
        comparatorMF3_2.setDescription("Meta");
        comparatorMF3_2.setComparation(comparationGoal);
        comparatorMF3_2.setPointer(pointerF3_2);
        delegate.createComparator(comparatorMF3_2);

        //Settings
        //Find the scorecard and dimensionalCut

        Comparator comparatorF3_2 = delegate.findComparator(pointerF3_2, comparationReal);
        Long idComparatorF3_2 = comparatorF3_2.getIdComparator();

        //Create setting to that pointer
        Settings settingF3_2 = (Settings) Factory.getBean("Settings");
        settingF3_2.setType(Settings.Type.SCORECARD);
        settingF3_2.setTemporality(Settings.Temporality.LAST);
        settingF3_2.setFrecuency(Settings.Frecuency.MONTHLY);
        settingF3_2.setMathOperation("P/" + "C" + idComparatorF3_2);
        settingF3_2.setPolarity(Settings.Polarity.LOW);

        settingF3_2.setScoreCard(pointerF3_2);
        delegate.createSettings(settingF3_2);

        pointerF3_2.setSettings(settingF3_2);
        delegate.updatePointer(pointerF3_2);


        //Settings de los comparators

        List<Comparator> comparatorsF3_2 = delegate.findComparator(pointerF3_2);
        for (Comparator comparator1 : comparatorsF3_2) {
            Settings settingComparator = (Settings) Factory.getBean("Settings");
            settingComparator.setType(Settings.Type.COMPARATOR);
            settingComparator.setCommand(Settings.Command.SUM);
            settingComparator.setComparator(comparator1);
            delegate.createSettings(settingComparator);

            comparator1.setSettings(settingComparator);
            delegate.updateComparator(comparator1);
        }



        //Populate DimensionalCut
        DimensionalCut dimensionalcut1F3_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1F3_2.setPointer(pointerF3_2);
        dimensionalcut1F3_2.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1F3_2);

        DimensionalCut dimensionalcut2F3_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut2F3_2.setPointer(pointerF3_2);
        dimensionalcut2F3_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut2F3_2);

        DimensionalCut dimensionalcut3F3_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut3F3_2.setPointer(pointerF3_2);
        dimensionalcut3F3_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut3F3_2);

        DimensionalCut dimensionalcut4F3_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut4F3_2.setPointer(pointerF3_2);
        dimensionalcut4F3_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut4F3_2);

        //Se crea la lista de cortes del indicador
        List<DimensionalCut> dimensionalCutsF3_2 = new ArrayList<DimensionalCut>();
        dimensionalCutsF3_2.add(dimensionalcut1F3_2);
        dimensionalCutsF3_2.add(dimensionalcut2F3_2);
        dimensionalCutsF3_2.add(dimensionalcut3F3_2);
        dimensionalCutsF3_2.add(dimensionalcut4F3_2);


        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm1F3_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm1F3_2.setDimensionMember(dimensionmember1Regiones);
        dcm1F3_2.setDimensionalCut(dimensionalcut1F3_2);
        delegate.createDimensionalCutMember(dcm1F3_2);

        DimensionalCutMember dcm2F3_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm2F3_2.setDimensionMember(dimensionmember2Regiones);
        dcm2F3_2.setDimensionalCut(dimensionalcut2F3_2);
        delegate.createDimensionalCutMember(dcm2F3_2);

        DimensionalCutMember dcm3F3_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm3F3_2.setDimensionMember(dimensionmember3Regiones);
        dcm3F3_2.setDimensionalCut(dimensionalcut3F3_2);
        delegate.createDimensionalCutMember(dcm3F3_2);

        DimensionalCutMember dcm4F3_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm4F3_2.setDimensionMember(dimensionmember4Regiones);
        dcm4F3_2.setDimensionalCut(dimensionalcut4F3_2);
        delegate.createDimensionalCutMember(dcm4F3_2);

        //Se METEN LOS DATOS AL INDICADOR
        //SE CREAN las matrices de datos
        Double realValuesF3_2[][] = {{3.6999999999999997D, 4.0D, 3.65D, 3.45D},
            {3.5000000000000004D, 2.8000000000000003D, 3.8D, 3.9D},
            {3.4000000000000004D, 2.7D, 3.6999999999999997D, 3.8D},
            {3.3000000000000003D, 3.5999999999999996D, 2.6D, 3.6999999999999997D},
            {3.8D, 3.75D, 3.9D, 3.75D},
            {3.5999999999999996D, 2.9000000000000004D, 3.9D, 4.0D}
        };


        Double metaValuesF3_2[][] = {{3.0D, 3.0D, 3.0D, 3.0D},
            {3.0D, 3.0D, 3.0D, 3.0D},
            {3.0D, 3.0D, 3.0D, 3.0D},
            {3.0D, 3.0D, 3.0D, 3.0D},
            {3.0D, 3.0D, 3.0D, 3.0D},
            {3.0D, 3.0D, 3.0D, 3.0D}
        };
        //Se crean las FECHAS
        List<Date> datesF3_2 = ScoreCardUtils.generateDatesRange(ScoreCardUtils.generateDate(1, 1, 2011), ScoreCardUtils.generateDate(1, 6, 2011), pointerF3_2);

        for (int i = 0; i < datesF3_2.size(); i++) {
            for (int j = 0; j < dimensionalCutsF3_2.size(); j++) {

                //Valor Real
                ComparatorDimensionalCut cdcRealF3_2 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcRealF3_2.setComparator(comparatorRF3_2);
                cdcRealF3_2.setDimensionalCut(dimensionalCutsF3_2.get(j));
                cdcRealF3_2.setRegisterDate(datesF3_2.get(i));
                cdcRealF3_2.setRegister(realValuesF3_2[i][j]);
                delegate.createComparatorDimensionalCut(cdcRealF3_2);

                //Valor Meta
                ComparatorDimensionalCut cdcMetaF3_2 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcMetaF3_2.setComparator(comparatorMF3_2);
                cdcMetaF3_2.setDimensionalCut(dimensionalCutsF3_2.get(j));
                cdcMetaF3_2.setRegisterDate(datesF3_2.get(i));
                cdcMetaF3_2.setRegister(metaValuesF3_2[i][j]);
                delegate.createComparatorDimensionalCut(cdcMetaF3_2);

            }
        }
        //INDICADORES
        //---------------------------FIN INDICADOR F3.2--------------------------------------------------------------------------------------





        //OBJETIVOS
        //-----------------------------------------SE CREA EL OBJETIVO F3------------------------------------------------------------------
        //Create Objetive Scorecard
        Objective objectiveScorecardF3 = (Objective) Factory.getBean("Objective");
        objectiveScorecardF3.setName("F3. Captar y retener clientes");
        objectiveScorecardF3.setDescription("Desarrollar una amplia cartera de Clientes, asegurando la permanencia de los actuales y atrayendo nuevos Clientes.");
        objectiveScorecardF3.setResponsable("Eduardo Romero");
        delegate.createObjective(objectiveScorecardF3);

        //-----------------------------------------FIN EL OBJETIVO F3------------------------------------------------------------------







        //INDICADORES
        //---------------------------INDICADOR F4.1--------------------------------------------------------------------------------------
        //Populate a new KPI
        Pointer pointerF4_1 = (Pointer) Factory.getBean("Pointer");
        pointerF4_1.setName("F4.1. Mix de ingresos");
        pointerF4_1.setDescription("Mide el índice de diversificación de productos basado en el total de venta que representa cada producto en el portafolio.");
        pointerF4_1.setResponsable("Jorge Villagrán");
        pointerF4_1.setUnit("(%)");
        delegate.createPointer(pointerF4_1);

        //Populate a new IndDim
        ScoreCardDimension scorecarddimensionF4_1 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionF4_1.setScoreCard(pointerF4_1);
        scorecarddimensionF4_1.setDimension(dimensionNormal);
        delegate.createScoreCardDimension(scorecarddimensionF4_1);

        //Populate a new Comparador Real
        Comparator comparatorRF4_1 = (Comparator) Factory.getBean("Comparator");
        comparatorRF4_1.setDescription("Real");
        comparatorRF4_1.setComparation(comparationReal);
        comparatorRF4_1.setPointer(pointerF4_1);
        delegate.createComparator(comparatorRF4_1);

        //Populate a new Comparador Meta
        Comparator comparatorMF4_1 = (Comparator) Factory.getBean("Comparator");
        comparatorMF4_1.setDescription("Meta");
        comparatorMF4_1.setComparation(comparationGoal);
        comparatorMF4_1.setPointer(pointerF4_1);
        delegate.createComparator(comparatorMF4_1);

        //Settings
        //Find the scorecard and dimensionalCut

        Comparator comparatorF4_1 = delegate.findComparator(pointerF4_1, comparationReal);
        Long idComparatorF4_1 = comparatorF4_1.getIdComparator();

        //Create setting to that pointer
        Settings settingF4_1 = (Settings) Factory.getBean("Settings");
        settingF4_1.setType(Settings.Type.SCORECARD);
        settingF4_1.setTemporality(Settings.Temporality.LAST);
        settingF4_1.setFrecuency(Settings.Frecuency.MONTHLY);
        settingF4_1.setMathOperation("C" + idComparatorF4_1 + "/P");
        settingF4_1.setPolarity(Settings.Polarity.HIGH);

        settingF4_1.setScoreCard(pointerF4_1);
        delegate.createSettings(settingF4_1);

        pointerF4_1.setSettings(settingF4_1);
        delegate.updatePointer(pointerF4_1);


        //Settings de los comparators

        List<Comparator> comparatorsF4_1 = delegate.findComparator(pointerF4_1);
        for (Comparator comparator1 : comparatorsF4_1) {
            Settings settingComparator = (Settings) Factory.getBean("Settings");
            settingComparator.setType(Settings.Type.COMPARATOR);
            settingComparator.setCommand(Settings.Command.SUM);
            settingComparator.setComparator(comparator1);
            delegate.createSettings(settingComparator);

            comparator1.setSettings(settingComparator);
            delegate.updateComparator(comparator1);
        }



        //Populate DimensionalCut
        DimensionalCut dimensionalcut1F4_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1F4_1.setPointer(pointerF4_1);
        dimensionalcut1F4_1.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1F4_1);



        //Se crea la lista de cortes del indicador
        List<DimensionalCut> dimensionalCutsF4_1 = new ArrayList<DimensionalCut>();
        dimensionalCutsF4_1.add(dimensionalcut1F4_1);



        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm1F4_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm1F4_1.setDimensionMember(dimensionmember1Normal);
        dcm1F4_1.setDimensionalCut(dimensionalcut1F4_1);
        delegate.createDimensionalCutMember(dcm1F4_1);


        //Se METEN LOS DATOS AL INDICADOR
        //SE CREAN las matrices de datos
        Double realValuesF4_1[][] = {{0.79D},
            {.85D},
            {.8D},
            {.92D},
            {.91D},
            {.91D}
        };


        Double metaValuesF4_1[][] = {{1D},
            {1D},
            {1D},
            {1D},
            {1D},
            {1D}
        };
        //Se crean las FECHAS
        List<Date> datesF4_1 = ScoreCardUtils.generateDatesRange(ScoreCardUtils.generateDate(1, 1, 2011), ScoreCardUtils.generateDate(1, 6, 2011), pointerF4_1);

        for (int i = 0; i < datesF4_1.size(); i++) {
            for (int j = 0; j < dimensionalCutsF4_1.size(); j++) {

                //Valor Real
                ComparatorDimensionalCut cdcRealF4_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcRealF4_1.setComparator(comparatorRF4_1);
                cdcRealF4_1.setDimensionalCut(dimensionalCutsF4_1.get(j));
                cdcRealF4_1.setRegisterDate(datesF4_1.get(i));
                cdcRealF4_1.setRegister(realValuesF4_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcRealF4_1);

                //Valor Meta
                ComparatorDimensionalCut cdcMetaF4_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcMetaF4_1.setComparator(comparatorMF4_1);
                cdcMetaF4_1.setDimensionalCut(dimensionalCutsF4_1.get(j));
                cdcMetaF4_1.setRegisterDate(datesF4_1.get(i));
                cdcMetaF4_1.setRegister(metaValuesF4_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcMetaF4_1);

            }
        }
        //INDICADORES
        //---------------------------FIN INDICADOR F4.1--------------------------------------------------------------------------------------

        //INDICADORES
        //---------------------------INDICADOR C1.1--------------------------------------------------------------------------------------
        //Populate a new KPI
        Pointer pointerC1_1 = (Pointer) Factory.getBean("Pointer");
        pointerC1_1.setName("C1.1. Venta negada");
        pointerC1_1.setDescription("Mide el monto perdido de venta por falta de inventario");
        pointerC1_1.setResponsable("Sergio Cruz");
        pointerC1_1.setUnit("($)");
        delegate.createPointer(pointerC1_1);

        //Populate a new IndDim
        ScoreCardDimension scorecarddimensionC1_1 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionC1_1.setScoreCard(pointerC1_1);
        scorecarddimensionC1_1.setDimension(dimensionProductos);
        delegate.createScoreCardDimension(scorecarddimensionC1_1);

        //Populate a new Comparador Real
        Comparator comparatorRC1_1 = (Comparator) Factory.getBean("Comparator");
        comparatorRC1_1.setDescription("Real");
        comparatorRC1_1.setComparation(comparationReal);
        comparatorRC1_1.setPointer(pointerC1_1);
        delegate.createComparator(comparatorRC1_1);

        //Populate a new Comparador Meta
        Comparator comparatorMC1_1 = (Comparator) Factory.getBean("Comparator");
        comparatorMC1_1.setDescription("Meta");
        comparatorMC1_1.setComparation(comparationGoal);
        comparatorMC1_1.setPointer(pointerC1_1);
        delegate.createComparator(comparatorMC1_1);

        //Settings
        //Find the scorecard and dimensionalCut

        Comparator comparatorC1_1 = delegate.findComparator(pointerC1_1, comparationReal);
        Long idComparatorC1_1 = comparatorC1_1.getIdComparator();

        //Create setting to that pointer
        Settings settingC1_1 = (Settings) Factory.getBean("Settings");
        settingC1_1.setType(Settings.Type.SCORECARD);
        settingC1_1.setTemporality(Settings.Temporality.LAST);
        settingC1_1.setFrecuency(Settings.Frecuency.MONTHLY);
        settingC1_1.setMathOperation("P/" + "C" + idComparatorC1_1);
        settingC1_1.setPolarity(Settings.Polarity.LOW);

        settingC1_1.setScoreCard(pointerC1_1);
        delegate.createSettings(settingC1_1);

        pointerC1_1.setSettings(settingC1_1);
        delegate.updatePointer(pointerC1_1);


        //Settings de los comparators

        List<Comparator> comparatorsC1_1 = delegate.findComparator(pointerC1_1);
        for (Comparator comparator1 : comparatorsC1_1) {
            Settings settingComparator = (Settings) Factory.getBean("Settings");
            settingComparator.setType(Settings.Type.COMPARATOR);
            settingComparator.setCommand(Settings.Command.SUM);
            settingComparator.setComparator(comparator1);
            delegate.createSettings(settingComparator);

            comparator1.setSettings(settingComparator);
            delegate.updateComparator(comparator1);
        }



        //Populate DimensionalCut
        DimensionalCut dimensionalcut1C1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1C1_1.setPointer(pointerC1_1);
        dimensionalcut1C1_1.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1C1_1);

        DimensionalCut dimensionalcut2C1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut2C1_1.setPointer(pointerC1_1);
        dimensionalcut2C1_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut2C1_1);

        DimensionalCut dimensionalcut3C1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut3C1_1.setPointer(pointerC1_1);
        dimensionalcut3C1_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut3C1_1);

        DimensionalCut dimensionalcut4C1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut4C1_1.setPointer(pointerC1_1);
        dimensionalcut4C1_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut4C1_1);

        //Se crea la lista de cortes del indicador
        List<DimensionalCut> dimensionalCutsC1_1 = new ArrayList<DimensionalCut>();
        dimensionalCutsC1_1.add(dimensionalcut1C1_1);
        dimensionalCutsC1_1.add(dimensionalcut2C1_1);
        dimensionalCutsC1_1.add(dimensionalcut3C1_1);
        dimensionalCutsC1_1.add(dimensionalcut4C1_1);


        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm1C1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm1C1_1.setDimensionMember(dimensionmember1Productos);
        dcm1C1_1.setDimensionalCut(dimensionalcut1C1_1);
        delegate.createDimensionalCutMember(dcm1C1_1);

        DimensionalCutMember dcm2C1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm2C1_1.setDimensionMember(dimensionmember2Productos);
        dcm2C1_1.setDimensionalCut(dimensionalcut2C1_1);
        delegate.createDimensionalCutMember(dcm2C1_1);

        DimensionalCutMember dcm3C1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm3C1_1.setDimensionMember(dimensionmember3Productos);
        dcm3C1_1.setDimensionalCut(dimensionalcut3C1_1);
        delegate.createDimensionalCutMember(dcm3C1_1);

        DimensionalCutMember dcm4C1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm4C1_1.setDimensionMember(dimensionmember4Productos);
        dcm4C1_1.setDimensionalCut(dimensionalcut4C1_1);
        delegate.createDimensionalCutMember(dcm4C1_1);

        //Se METEN LOS DATOS AL INDICADOR
        //SE CREAN las matrices de datos
        Double realValuesC1_1[][] = {{824994.0D, 494996.39999999997D, 123749.09999999999D, 206248.5D},
            {870125.0D, 348050.0D, 217531.25D, 304543.75D},
            {832119.0D, 332847.60000000003D, 208029.75D, 291241.64999999997D},
            {760800.0D, 456480.0D, 190200.0D, 114120.0D},
            {833053.0D, 333221.2D, 208263.25D, 291568.55D},
            {774023.0D, 387011.5D, 193505.75D, 193505.75D}
        };



        Double metaValuesC1_1[][] = {{500000.0D, 250000.0D, 150000.0D, 100000.0D},
            {500000.0D, 250000.0D, 150000.0D, 100000.0D},
            {500000.0D, 250000.0D, 150000.0D, 100000.0D},
            {500000.0D, 250000.0D, 150000.0D, 100000.0D},
            {500000.0D, 250000.0D, 150000.0D, 100000.0D},
            {500000.0D, 250000.0D, 150000.0D, 100000.0D}
        };

        //Se crean las FECHAS
        List<Date> datesC1_1 = ScoreCardUtils.generateDatesRange(ScoreCardUtils.generateDate(1, 1, 2011), ScoreCardUtils.generateDate(1, 6, 2011), pointerC1_1);

        for (int i = 0; i < datesC1_1.size(); i++) {
            for (int j = 0; j < dimensionalCutsC1_1.size(); j++) {
                //System.out.println("Fecha Generada: " + datesC1_1.get(i));
                //Valor Real
                ComparatorDimensionalCut cdcRealC1_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcRealC1_1.setComparator(comparatorRC1_1);
                cdcRealC1_1.setDimensionalCut(dimensionalCutsC1_1.get(j));
                cdcRealC1_1.setRegisterDate(datesC1_1.get(i));
                cdcRealC1_1.setRegister(realValuesC1_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcRealC1_1);

                //Valor Meta
                ComparatorDimensionalCut cdcMetaC1_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcMetaC1_1.setComparator(comparatorMC1_1);
                cdcMetaC1_1.setDimensionalCut(dimensionalCutsC1_1.get(j));
                cdcMetaC1_1.setRegisterDate(datesC1_1.get(i));
                cdcMetaC1_1.setRegister(metaValuesC1_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcMetaC1_1);

            }
        }
        //INDICADORES
        //---------------------------FIN INDICADOR C1.1--------------------------------------------------------------------------------------


        //INDICADORES
        //---------------------------INDICADOR C1.2--------------------------------------------------------------------------------------
        //Populate a new KPI
        Pointer pointerC1_2 = (Pointer) Factory.getBean("Pointer");
        pointerC1_2.setName("C1.2. Share of inventory");
        pointerC1_2.setDescription("Mide la presencia de producto de Néctares del Sureste en anaqueles en relación al total de productos colocados en dichos anaqueles.");
        pointerC1_2.setResponsable("Sergio Cruz");
        pointerC1_2.setUnit("(%)");
        delegate.createPointer(pointerC1_2);

        //Populate a new IndDim
        ScoreCardDimension scorecarddimensionC1_2 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionC1_2.setScoreCard(pointerC1_2);
        scorecarddimensionC1_2.setDimension(dimensionRegiones);
        delegate.createScoreCardDimension(scorecarddimensionC1_2);

        //Populate a new Comparador Real
        Comparator comparatorRC1_2 = (Comparator) Factory.getBean("Comparator");
        comparatorRC1_2.setDescription("Real");
        comparatorRC1_2.setComparation(comparationReal);
        comparatorRC1_2.setPointer(pointerC1_2);
        delegate.createComparator(comparatorRC1_2);

        //Populate a new Comparador Meta
        Comparator comparatorMC1_2 = (Comparator) Factory.getBean("Comparator");
        comparatorMC1_2.setDescription("Meta");
        comparatorMC1_2.setComparation(comparationGoal);
        comparatorMC1_2.setPointer(pointerC1_2);
        delegate.createComparator(comparatorMC1_2);

        //Settings
        //Find the scorecard and dimensionalCut

        Comparator comparatorC1_2 = delegate.findComparator(pointerC1_2, comparationReal);
        Long idComparatorC1_2 = comparatorC1_2.getIdComparator();

        //Create setting to that pointer
        Settings settingC1_2 = (Settings) Factory.getBean("Settings");
        settingC1_2.setType(Settings.Type.SCORECARD);
        settingC1_2.setTemporality(Settings.Temporality.LAST);
        settingC1_2.setFrecuency(Settings.Frecuency.QUARTERLY);
        settingC1_2.setMathOperation("C" + idComparatorC1_2 + "/P");
        settingC1_2.setPolarity(Settings.Polarity.HIGH);

        settingC1_2.setScoreCard(pointerC1_2);
        delegate.createSettings(settingC1_2);

        pointerC1_2.setSettings(settingC1_2);
        delegate.updatePointer(pointerC1_2);


        //Settings de los comparators

        List<Comparator> comparatorsC1_2 = delegate.findComparator(pointerC1_2);
        for (Comparator comparator1 : comparatorsC1_2) {
            Settings settingComparator = (Settings) Factory.getBean("Settings");
            settingComparator.setType(Settings.Type.COMPARATOR);
            settingComparator.setCommand(Settings.Command.SUM);
            settingComparator.setComparator(comparator1);
            delegate.createSettings(settingComparator);

            comparator1.setSettings(settingComparator);
            delegate.updateComparator(comparator1);
        }



        //Populate DimensionalCut
        DimensionalCut dimensionalcut1C1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1C1_2.setPointer(pointerC1_2);
        dimensionalcut1C1_2.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1C1_2);

        DimensionalCut dimensionalcut2C1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut2C1_2.setPointer(pointerC1_2);
        dimensionalcut2C1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut2C1_2);

        DimensionalCut dimensionalcut3C1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut3C1_2.setPointer(pointerC1_2);
        dimensionalcut3C1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut3C1_2);

        DimensionalCut dimensionalcut4C1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut4C1_2.setPointer(pointerC1_2);
        dimensionalcut4C1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut4C1_2);

        //Se crea la lista de cortes del indicador
        List<DimensionalCut> dimensionalCutsC1_2 = new ArrayList<DimensionalCut>();
        dimensionalCutsC1_2.add(dimensionalcut1C1_2);
        dimensionalCutsC1_2.add(dimensionalcut2C1_2);
        dimensionalCutsC1_2.add(dimensionalcut3C1_2);
        dimensionalCutsC1_2.add(dimensionalcut4C1_2);


        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm1C1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm1C1_2.setDimensionMember(dimensionmember1Regiones);
        dcm1C1_2.setDimensionalCut(dimensionalcut1C1_2);
        delegate.createDimensionalCutMember(dcm1C1_2);

        DimensionalCutMember dcm2C1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm2C1_2.setDimensionMember(dimensionmember2Regiones);
        dcm2C1_2.setDimensionalCut(dimensionalcut2C1_2);
        delegate.createDimensionalCutMember(dcm2C1_2);

        DimensionalCutMember dcm3C1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm3C1_2.setDimensionMember(dimensionmember3Regiones);
        dcm3C1_2.setDimensionalCut(dimensionalcut3C1_2);
        delegate.createDimensionalCutMember(dcm3C1_2);

        DimensionalCutMember dcm4C1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm4C1_2.setDimensionMember(dimensionmember4Regiones);
        dcm4C1_2.setDimensionalCut(dimensionalcut4C1_2);
        delegate.createDimensionalCutMember(dcm4C1_2);

        //Se METEN LOS DATOS AL INDICADOR
        //SE CREAN las matrices de datos
        Double realValuesC1_2[][] = {{11.5D, 14.499999999999998D, 8.5D, 11.5D},
            {12.2D, 11.799999999999999D, 12.6D, 12.2D}
        };



        Double metaValuesC1_2[][] = {{15.0D, 15.0D, 15.0D, 15.0D},
            {15.0D, 15.0D, 15.0D, 15.0D}};

        //Se crean las FECHAS


        List<Date> datesC1_2 = ScoreCardUtils.generateDatesRange(ScoreCardUtils.generateDate(1, 1, 2011), ScoreCardUtils.generateDate(1, 6, 2011), pointerC1_2);

        for (int i = 0; i < datesC1_2.size(); i++) {
            for (int j = 0; j < dimensionalCutsC1_2.size(); j++) {
                System.out.println("Fecha Generada: " + datesC1_2.get(i));

                //Valor Real
                ComparatorDimensionalCut cdcRealC1_2 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcRealC1_2.setComparator(comparatorRC1_2);
                cdcRealC1_2.setDimensionalCut(dimensionalCutsC1_2.get(j));
                cdcRealC1_2.setRegisterDate(datesC1_2.get(i));
                cdcRealC1_2.setRegister(realValuesC1_2[i][j]);
                delegate.createComparatorDimensionalCut(cdcRealC1_2);

                //Valor Meta
                ComparatorDimensionalCut cdcMetaC1_2 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcMetaC1_2.setComparator(comparatorMC1_2);
                cdcMetaC1_2.setDimensionalCut(dimensionalCutsC1_2.get(j));
                cdcMetaC1_2.setRegisterDate(datesC1_2.get(i));
                cdcMetaC1_2.setRegister(metaValuesC1_2[i][j]);
                delegate.createComparatorDimensionalCut(cdcMetaC1_2);

            }
        }
        //INDICADORES
        //---------------------------FIN INDICADOR C1.2--------------------------------------------------------------------------------------

        //INDICADORES
        //---------------------------INDICADOR P1.1--------------------------------------------------------------------------------------
        //Populate a new KPI
        Pointer pointerP1_1 = (Pointer) Factory.getBean("Pointer");
        pointerP1_1.setName("P1.1. Ordenes perfectas-distribución");
        pointerP1_1.setDescription("Mide el porcentaje de ordenes entregadas en tiempo y forma.");
        pointerP1_1.setResponsable("Sergio Cruz");
        pointerP1_1.setUnit("(%)");
        delegate.createPointer(pointerP1_1);

        //Populate a new IndDim
        ScoreCardDimension scorecarddimensionP1_1 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionP1_1.setScoreCard(pointerP1_1);
        scorecarddimensionP1_1.setDimension(dimensionNormal);
        delegate.createScoreCardDimension(scorecarddimensionP1_1);

        //Populate a new Comparador Real
        Comparator comparatorRP1_1 = (Comparator) Factory.getBean("Comparator");
        comparatorRP1_1.setDescription("Real");
        comparatorRP1_1.setComparation(comparationReal);
        comparatorRP1_1.setPointer(pointerP1_1);
        delegate.createComparator(comparatorRP1_1);

        //Populate a new Comparador Meta
        Comparator comparatorMP1_1 = (Comparator) Factory.getBean("Comparator");
        comparatorMP1_1.setDescription("Meta");
        comparatorMP1_1.setComparation(comparationGoal);
        comparatorMP1_1.setPointer(pointerP1_1);
        delegate.createComparator(comparatorMP1_1);

        //Settings
        //Find the scorecard and dimensionalCut

        Comparator comparatorP1_1 = delegate.findComparator(pointerP1_1, comparationReal);
        Long idComparatorP1_1 = comparatorP1_1.getIdComparator();

        //Create setting to that pointer
        Settings settingP1_1 = (Settings) Factory.getBean("Settings");
        settingP1_1.setType(Settings.Type.SCORECARD);
        settingP1_1.setTemporality(Settings.Temporality.LAST);
        settingP1_1.setFrecuency(Settings.Frecuency.MONTHLY);
        settingP1_1.setMathOperation("C" + idComparatorP1_1 + "/P");
        settingP1_1.setPolarity(Settings.Polarity.HIGH);

        settingP1_1.setScoreCard(pointerP1_1);
        delegate.createSettings(settingP1_1);

        pointerP1_1.setSettings(settingP1_1);
        delegate.updatePointer(pointerP1_1);


        //Settings de los comparators

        List<Comparator> comparatorsP1_1 = delegate.findComparator(pointerP1_1);
        for (Comparator comparator1 : comparatorsP1_1) {
            Settings settingComparator = (Settings) Factory.getBean("Settings");
            settingComparator.setType(Settings.Type.COMPARATOR);
            settingComparator.setCommand(Settings.Command.SUM);
            settingComparator.setComparator(comparator1);
            delegate.createSettings(settingComparator);

            comparator1.setSettings(settingComparator);
            delegate.updateComparator(comparator1);
        }



        //Populate DimensionalCut
        DimensionalCut dimensionalcut1P1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1P1_1.setPointer(pointerP1_1);
        dimensionalcut1P1_1.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1P1_1);



        //Se crea la lista de cortes del indicador
        List<DimensionalCut> dimensionalCutsP1_1 = new ArrayList<DimensionalCut>();
        dimensionalCutsP1_1.add(dimensionalcut1P1_1);



        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm1P1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm1P1_1.setDimensionMember(dimensionmember1Normal);
        dcm1P1_1.setDimensionalCut(dimensionalcut1P1_1);
        delegate.createDimensionalCutMember(dcm1P1_1);


        //Se METEN LOS DATOS AL INDICADOR
        //SE CREAN las matrices de datos
        Double realValuesP1_1[][] = {{81D},
            {80D},
            {78D},
            {62D},
            {75D},
            {76D}
        };


        Double metaValuesP1_1[][] = {{98D},
            {98D},
            {98D},
            {98D},
            {98D},
            {98D}
        };
        //Se crean las FECHAS
        List<Date> datesP1_1 = ScoreCardUtils.generateDatesRange(ScoreCardUtils.generateDate(1, 1, 2011), ScoreCardUtils.generateDate(1, 6, 2011), pointerP1_1);
        for (int i = 0; i < datesP1_1.size(); i++) {
            for (int j = 0; j < dimensionalCutsP1_1.size(); j++) {

                //Valor Real
                ComparatorDimensionalCut cdcRealP1_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcRealP1_1.setComparator(comparatorRP1_1);
                cdcRealP1_1.setDimensionalCut(dimensionalCutsP1_1.get(j));
                cdcRealP1_1.setRegisterDate(datesP1_1.get(i));
                cdcRealP1_1.setRegister(realValuesP1_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcRealP1_1);

                //Valor Meta
                ComparatorDimensionalCut cdcMetaP1_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcMetaP1_1.setComparator(comparatorMP1_1);
                cdcMetaP1_1.setDimensionalCut(dimensionalCutsP1_1.get(j));
                cdcMetaP1_1.setRegisterDate(datesP1_1.get(i));
                cdcMetaP1_1.setRegister(metaValuesP1_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcMetaP1_1);

            }
        }
        //INDICADORES
        //---------------------------FIN INDICADOR P1.1--------------------------------------------------------------------------------------



        //---------------------------PROYECTO 1--------------------------------------------------------------------------------------

        //Create Project
        Project projectP1 = (Project) Factory.getBean("Project");
        projectP1.setName("Proyeto P1");
        projectP1.setDescription("Mejorar las rutas de distribucion implementando el sistema RoutingMaps");
        projectP1.setResponsable("Miguel Angel López");
        delegate.createProject(projectP1);

        Tracer tracerBudgetP1 = (Tracer) Factory.getBean("Tracer");
        tracerBudgetP1.setName("Presupuesto");
        tracerBudgetP1.setPercentFactor(.5);
        tracerBudgetP1.setType(Tracer.Type.BUDGET);
        tracerBudgetP1.setProject(projectP1);
        delegate.createTracer(tracerBudgetP1);

        Tracer tracerProgressP1 = (Tracer) Factory.getBean("Tracer");
        tracerProgressP1.setName("Avance");
        tracerProgressP1.setPercentFactor(.5);
        tracerProgressP1.setType(Tracer.Type.PROGRESS);
        tracerProgressP1.setProject(projectP1);
        delegate.createTracer(tracerProgressP1);


        //HITO RAIZ
        //Create Label
        Label labelRootP1 = (Label) Factory.getBean("Label");
        labelRootP1.setName("Proyecto P1");
        labelRootP1.setProject(projectP1);
        labelRootP1.setRoot(Boolean.TRUE);
        delegate.createLabel(labelRootP1);

        //Create Milestone 1
        Milestone milestoneP1_1 = (Milestone) Factory.getBean("Milestone");
        milestoneP1_1.setName("Analisis de puntos de distribucion");
        //Fecha de 27-jun-11
        milestoneP1_1.setBeginDate(ScoreCardUtils.generateDate(27, 6, 2011));
        //Fecha de 01-jul-11
        milestoneP1_1.setEndDate(ScoreCardUtils.generateDate(1, 7, 2011));
        milestoneP1_1.setTask(labelRootP1);
        milestoneP1_1.setProject(projectP1);
        milestoneP1_1.setRoot(Boolean.FALSE);
        delegate.createMilestone(milestoneP1_1);

        //Create Milestone 2
        Milestone milestoneP1_2 = (Milestone) Factory.getBean("Milestone");
        milestoneP1_2.setName("Diseno de parametros para el sistema");
        //Fecha de 04-jul-11
        milestoneP1_2.setBeginDate(ScoreCardUtils.generateDate(4, 7, 2011));
        //Fecha de 22-jul-11
        milestoneP1_2.setEndDate(ScoreCardUtils.generateDate(22, 7, 2011));
        milestoneP1_2.setTask(labelRootP1);
        milestoneP1_2.setProject(projectP1);
        milestoneP1_2.setRoot(Boolean.FALSE);
        delegate.createMilestone(milestoneP1_2);

        //Create Milestone 3
        Milestone milestoneP1_3 = (Milestone) Factory.getBean("Milestone");
        milestoneP1_3.setName("Configuracion del sistema");
        //Fecha de 25-jul-11
        milestoneP1_3.setBeginDate(ScoreCardUtils.generateDate(25, 7, 2011));
        //Fecha de 19-ago-11
        milestoneP1_3.setEndDate(ScoreCardUtils.generateDate(19, 8, 2011));
        milestoneP1_3.setTask(labelRootP1);
        milestoneP1_3.setProject(projectP1);
        milestoneP1_3.setRoot(Boolean.FALSE);
        delegate.createMilestone(milestoneP1_3);

        //Create Milestone 4
        Milestone milestoneP1_4 = (Milestone) Factory.getBean("Milestone");
        milestoneP1_4.setName("Puesta en productivo");
        //Fecha de 22-ago-11
        milestoneP1_4.setBeginDate(ScoreCardUtils.generateDate(22, 8, 2011));
        //Fecha de 23-ago-11
        milestoneP1_4.setEndDate(ScoreCardUtils.generateDate(25, 8, 2011));
        milestoneP1_4.setTask(labelRootP1);
        milestoneP1_4.setProject(projectP1);
        milestoneP1_4.setRoot(Boolean.FALSE);
        delegate.createMilestone(milestoneP1_4);
        //---------------------------PROYECTO 1--------------------------------------------------------------------------------------
        //MILESTONETRACERS!!!!
        //MileStone 1 Tracer Progress
        MilestoneTracer milestone1Tracer1 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestone1Tracer1.setMilestone(milestoneP1_1);
        milestone1Tracer1.setTracer(tracerProgressP1);
        milestone1Tracer1.setRealValue(1D);

        //MileStone 1 Tracer Budget
        MilestoneTracer milestone1Tracer2 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestone1Tracer2.setMilestone(milestoneP1_1);
        milestone1Tracer2.setTracer(tracerBudgetP1);
        milestone1Tracer2.setRealValue(11000D);
        milestone1Tracer2.setGoalValue(10000D);

        //MileStone 2 Tracer Progress
        MilestoneTracer milestone2Tracer1 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestone2Tracer1.setMilestone(milestoneP1_2);
        milestone2Tracer1.setTracer(tracerProgressP1);
        milestone2Tracer1.setRealValue(.9D);

        //MileStone 2 Tracer Budget
        MilestoneTracer milestone2Tracer2 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestone2Tracer2.setMilestone(milestoneP1_2);
        milestone2Tracer2.setTracer(tracerBudgetP1);
        milestone2Tracer2.setRealValue(25000D);
        milestone2Tracer2.setGoalValue(18000D);

        //MileStone 3 Tracer Progress
        MilestoneTracer milestone3Tracer1 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestone3Tracer1.setMilestone(milestoneP1_3);
        milestone3Tracer1.setTracer(tracerProgressP1);
        milestone3Tracer1.setRealValue(.3D);

        //MileStone 3 Tracer Budget
        MilestoneTracer milestone3Tracer2 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestone3Tracer2.setMilestone(milestoneP1_3);
        milestone3Tracer2.setTracer(tracerBudgetP1);
        milestone3Tracer2.setRealValue(15000D);
        milestone3Tracer2.setGoalValue(4000D);


        //MileStone 4 Tracer Progress
        MilestoneTracer milestone4Tracer1 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestone4Tracer1.setMilestone(milestoneP1_4);
        milestone4Tracer1.setTracer(tracerProgressP1);
        milestone4Tracer1.setRealValue(0D);

        //MileStone 4 Tracer Budget
        MilestoneTracer milestone4Tracer2 = (MilestoneTracer) Factory.getBean("MilestoneTracer");
        milestone4Tracer2.setMilestone(milestoneP1_4);
        milestone4Tracer2.setTracer(tracerBudgetP1);
        milestone4Tracer2.setRealValue(1000D);
        milestone4Tracer2.setGoalValue(4000D);

        delegate.createMilestoneTracer(milestone1Tracer1);
        delegate.createMilestoneTracer(milestone1Tracer2);

        delegate.createMilestoneTracer(milestone2Tracer1);
        delegate.createMilestoneTracer(milestone2Tracer2);

        delegate.createMilestoneTracer(milestone3Tracer1);
        delegate.createMilestoneTracer(milestone3Tracer2);

        delegate.createMilestoneTracer(milestone4Tracer1);
        delegate.createMilestoneTracer(milestone4Tracer2);

        //------------------------FIN PROYECTO 1----------------------------------------------


        //INDICADORES
        //---------------------------INDICADOR A1.1--------------------------------------------------------------------------------------
        //Populate a new KPI
        Pointer pointerA1_1 = (Pointer) Factory.getBean("Pointer");
        pointerA1_1.setName("A1.1. Disponibilidad sistemas información");
        pointerA1_1.setDescription("Mide la disponibilidad de los sistemas de información que apoyan la operación" + "\n" +
                "- ERP (Planeación de recursos empresariales)" + "\n" +
                "- CRM (Customer Relationship Management)" + "\n" +
                "- SAP (Manufacturing)");
        pointerA1_1.setResponsable("Federico Sanchez");
        pointerA1_1.setUnit("(%)");
        delegate.createPointer(pointerA1_1);

        //Populate a new IndDim
        ScoreCardDimension scorecarddimensionA1_1 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionA1_1.setScoreCard(pointerA1_1);
        scorecarddimensionA1_1.setDimension(dimensionSistemas);
        delegate.createScoreCardDimension(scorecarddimensionA1_1);

        //Populate a new Comparador Real
        Comparator comparatorRA1_1 = (Comparator) Factory.getBean("Comparator");
        comparatorRA1_1.setDescription("Real");
        comparatorRA1_1.setComparation(comparationReal);
        comparatorRA1_1.setPointer(pointerA1_1);
        delegate.createComparator(comparatorRA1_1);

        //Populate a new Comparador Meta
        Comparator comparatorMA1_1 = (Comparator) Factory.getBean("Comparator");
        comparatorMA1_1.setDescription("Meta");
        comparatorMA1_1.setComparation(comparationGoal);
        comparatorMA1_1.setPointer(pointerA1_1);
        delegate.createComparator(comparatorMA1_1);

        //Settings
        //Find the scorecard and dimensionalCut

        Comparator comparatorA1_1 = delegate.findComparator(pointerA1_1, comparationReal);
        Long idComparatorA1_1 = comparatorA1_1.getIdComparator();

        //Create setting to that pointer
        Settings settingA1_1 = (Settings) Factory.getBean("Settings");
        settingA1_1.setType(Settings.Type.SCORECARD);
        settingA1_1.setTemporality(Settings.Temporality.LAST);
        settingA1_1.setFrecuency(Settings.Frecuency.MONTHLY);
        settingA1_1.setMathOperation("C" + idComparatorA1_1 + "/P");
        settingA1_1.setPolarity(Settings.Polarity.HIGH);
        settingA1_1.setScoreCard(pointerA1_1);
        delegate.createSettings(settingA1_1);

        pointerA1_1.setSettings(settingA1_1);
        delegate.updatePointer(pointerA1_1);


        //Settings de los comparators

        List<Comparator> comparatorsA1_1 = delegate.findComparator(pointerA1_1);
        for (Comparator comparator1 : comparatorsA1_1) {
            Settings settingComparator = (Settings) Factory.getBean("Settings");
            settingComparator.setType(Settings.Type.COMPARATOR);
            settingComparator.setCommand(Settings.Command.SUM);
            settingComparator.setComparator(comparator1);
            delegate.createSettings(settingComparator);

            comparator1.setSettings(settingComparator);
            delegate.updateComparator(comparator1);
        }



        //Populate DimensionalCut
        DimensionalCut dimensionalcut1A1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1A1_1.setPointer(pointerA1_1);
        dimensionalcut1A1_1.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1A1_1);

        DimensionalCut dimensionalcut2A1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut2A1_1.setPointer(pointerA1_1);
        dimensionalcut2A1_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut2A1_1);

        DimensionalCut dimensionalcut3A1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut3A1_1.setPointer(pointerA1_1);
        dimensionalcut3A1_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut3A1_1);

        DimensionalCut dimensionalcut4A1_1 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut4A1_1.setPointer(pointerA1_1);
        dimensionalcut4A1_1.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut4A1_1);

        //Se crea la lista de cortes del indicador
        List<DimensionalCut> dimensionalCutsA1_1 = new ArrayList<DimensionalCut>();
        dimensionalCutsA1_1.add(dimensionalcut1A1_1);
        dimensionalCutsA1_1.add(dimensionalcut2A1_1);
        dimensionalCutsA1_1.add(dimensionalcut3A1_1);
        dimensionalCutsA1_1.add(dimensionalcut4A1_1);


        //Populate DimensionalCut-DimensionalMember
        DimensionalCutMember dcm1A1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm1A1_1.setDimensionMember(dimensionmember1Sistemas);
        dcm1A1_1.setDimensionalCut(dimensionalcut1A1_1);
        delegate.createDimensionalCutMember(dcm1A1_1);

        DimensionalCutMember dcm2A1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm2A1_1.setDimensionMember(dimensionmember2Sistemas);
        dcm2A1_1.setDimensionalCut(dimensionalcut2A1_1);
        delegate.createDimensionalCutMember(dcm2A1_1);

        DimensionalCutMember dcm3A1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm3A1_1.setDimensionMember(dimensionmember3Sistemas);
        dcm3A1_1.setDimensionalCut(dimensionalcut3A1_1);
        delegate.createDimensionalCutMember(dcm3A1_1);

        DimensionalCutMember dcm4A1_1 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm4A1_1.setDimensionMember(dimensionmember4Sistemas);
        dcm4A1_1.setDimensionalCut(dimensionalcut4A1_1);
        delegate.createDimensionalCutMember(dcm4A1_1);

        //Se METEN LOS DATOS AL INDICADOR
        //SE CREAN las matrices de datos
        Double realValuesA1_1[][] = {{70.0D, 80.0D, 65.0D, 65.0D},
            {75.0D, 70.0D, 80.0D, 75.0D},
            {78.0D, 82.0D, 80.0D, 72.0D},
            {74.0D, 80.0D, 76.0D, 66.0D},
            {71.0D, 85.0D, 65.0D, 63.0D},
            {76.0D, 78.0D, 74.0D, 76.0D}
        };


        Double metaValuesA1_1[][] = {{99.0D, 99.0D, 99.0D, 99.0D},
            {99.0D, 99.0D, 99.0D, 99.0D},
            {99.0D, 99.0D, 99.0D, 99.0D},
            {99.0D, 99.0D, 99.0D, 99.0D},
            {99.0D, 99.0D, 99.0D, 99.0D},
            {99.0D, 99.0D, 99.0D, 99.0D}
        };

        //Se crean las FECHAS
        List<Date> datesA1_1 = ScoreCardUtils.generateDatesRange(ScoreCardUtils.generateDate(1, 1, 2011), ScoreCardUtils.generateDate(1, 6, 2011), pointerA1_1);

        for (int i = 0; i < datesA1_1.size(); i++) {
            for (int j = 0; j < dimensionalCutsA1_1.size(); j++) {

                //Valor Real
                ComparatorDimensionalCut cdcRealA1_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcRealA1_1.setComparator(comparatorRA1_1);
                cdcRealA1_1.setDimensionalCut(dimensionalCutsA1_1.get(j));
                cdcRealA1_1.setRegisterDate(datesA1_1.get(i));
                cdcRealA1_1.setRegister(realValuesA1_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcRealA1_1);

                //Valor Meta
                ComparatorDimensionalCut cdcMetaA1_1 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcMetaA1_1.setComparator(comparatorMA1_1);
                cdcMetaA1_1.setDimensionalCut(dimensionalCutsA1_1.get(j));
                cdcMetaA1_1.setRegisterDate(datesA1_1.get(i));
                cdcMetaA1_1.setRegister(metaValuesA1_1[i][j]);
                delegate.createComparatorDimensionalCut(cdcMetaA1_1);

            }
        }
        //INDICADORES
        //---------------------------FIN INDICADOR A1.1--------------------------------------------------------------------------------------



        //INDICADORES
        //---------------------------INDICADOR A1_2--------------------------------------------------------------------------------------
        //Populate a new KPI
        Pointer pointerA1_2 = (Pointer) Factory.getBean("Pointer");
        pointerA1_2.setName("A1.2 Disponibilidad sistemas información con los productos");
        pointerA1_2.setDescription("Mide la disponibilidad de los sistemas de información que apoyan la operación" + "\n" +
                "- ERP (Planeación de recursos empresariales)" + "\n" +
                "- CRM (Customer Relationship Management)" + "\n" +
                "- SAP (Manufacturing)");
        pointerA1_2.setResponsable("Federico Sanchez");
        pointerA1_2.setUnit("(%)");
        delegate.createPointer(pointerA1_2);

        //Populate a new IndDim
        ScoreCardDimension scorecarddimensionA1_2 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionA1_2.setScoreCard(pointerA1_2);
        scorecarddimensionA1_2.setDimension(dimensionSistemas);
        delegate.createScoreCardDimension(scorecarddimensionA1_2);

        ScoreCardDimension scorecarddimensionA1_2_2 = (ScoreCardDimension) Factory.getBean("ScoreCardDimension");
        scorecarddimensionA1_2_2.setScoreCard(pointerA1_2);
        scorecarddimensionA1_2_2.setDimension(dimensionProductos);
        delegate.createScoreCardDimension(scorecarddimensionA1_2_2);

        //Populate a new Comparador Real
        Comparator comparatorRA1_2 = (Comparator) Factory.getBean("Comparator");
        comparatorRA1_2.setDescription("Real");
        comparatorRA1_2.setComparation(comparationReal);
        comparatorRA1_2.setPointer(pointerA1_2);
        delegate.createComparator(comparatorRA1_2);

        //Populate a new Comparador Meta
        Comparator comparatorMA1_2 = (Comparator) Factory.getBean("Comparator");
        comparatorMA1_2.setDescription("Meta");
        comparatorMA1_2.setComparation(comparationGoal);
        comparatorMA1_2.setPointer(pointerA1_2);
        delegate.createComparator(comparatorMA1_2);

        //Settings
        //Find the scorecard and dimensionalCut

        Comparator comparatorA1_2 = delegate.findComparator(pointerA1_2, comparationReal);
        Long idComparatorA1_2 = comparatorA1_2.getIdComparator();

        //Create setting to that pointer
        Settings settingA1_2 = (Settings) Factory.getBean("Settings");
        settingA1_2.setType(Settings.Type.SCORECARD);
        settingA1_2.setTemporality(Settings.Temporality.LAST);
        settingA1_2.setFrecuency(Settings.Frecuency.MONTHLY);
        settingA1_2.setMathOperation("C" + idComparatorA1_2 + "/P");
        settingA1_2.setPolarity(Settings.Polarity.HIGH);
        settingA1_2.setScoreCard(pointerA1_2);
        delegate.createSettings(settingA1_2);

        pointerA1_2.setSettings(settingA1_2);
        delegate.updatePointer(pointerA1_2);


        //Settings de los comparators

        List<Comparator> comparatorsA1_2 = delegate.findComparator(pointerA1_2);
        for (Comparator comparator1 : comparatorsA1_2) {
            Settings settingComparator = (Settings) Factory.getBean("Settings");
            settingComparator.setType(Settings.Type.COMPARATOR);
            settingComparator.setCommand(Settings.Command.SUM);
            settingComparator.setComparator(comparator1);
            delegate.createSettings(settingComparator);

            comparator1.setSettings(settingComparator);
            delegate.updateComparator(comparator1);
        }



        //Populate DimensionalCut
        DimensionalCut dimensionalcut1A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut1A1_2.setPointer(pointerA1_2);
        dimensionalcut1A1_2.setType(DimensionalCut.Type.TOTAL);
        delegate.createDimensionalCut(dimensionalcut1A1_2);

        DimensionalCut dimensionalcut2A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut2A1_2.setPointer(pointerA1_2);
        dimensionalcut2A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut2A1_2);

        DimensionalCut dimensionalcut3A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut3A1_2.setPointer(pointerA1_2);
        dimensionalcut3A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut3A1_2);

        DimensionalCut dimensionalcut4A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut4A1_2.setPointer(pointerA1_2);
        dimensionalcut4A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut4A1_2);

        DimensionalCut dimensionalcut5A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut5A1_2.setPointer(pointerA1_2);
        dimensionalcut5A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut5A1_2);

        DimensionalCut dimensionalcut6A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut6A1_2.setPointer(pointerA1_2);
        dimensionalcut6A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut6A1_2);

        DimensionalCut dimensionalcut7A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut7A1_2.setPointer(pointerA1_2);
        dimensionalcut7A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut7A1_2);

        DimensionalCut dimensionalcut8A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut8A1_2.setPointer(pointerA1_2);
        dimensionalcut8A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut8A1_2);

        DimensionalCut dimensionalcut9A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut9A1_2.setPointer(pointerA1_2);
        dimensionalcut9A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut9A1_2);

        DimensionalCut dimensionalcut10A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut10A1_2.setPointer(pointerA1_2);
        dimensionalcut10A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut10A1_2);

        DimensionalCut dimensionalcut11A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut11A1_2.setPointer(pointerA1_2);
        dimensionalcut11A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut11A1_2);

        DimensionalCut dimensionalcut12A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut12A1_2.setPointer(pointerA1_2);
        dimensionalcut12A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut12A1_2);

        DimensionalCut dimensionalcut13A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut13A1_2.setPointer(pointerA1_2);
        dimensionalcut13A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut13A1_2);

        DimensionalCut dimensionalcut14A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut14A1_2.setPointer(pointerA1_2);
        dimensionalcut14A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut14A1_2);

        DimensionalCut dimensionalcut15A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut15A1_2.setPointer(pointerA1_2);
        dimensionalcut15A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut15A1_2);

        DimensionalCut dimensionalcut16A1_2 = (DimensionalCut) Factory.getBean("DimensionalCut");
        dimensionalcut16A1_2.setPointer(pointerA1_2);
        dimensionalcut16A1_2.setType(DimensionalCut.Type.STANDARD);
        delegate.createDimensionalCut(dimensionalcut16A1_2);

        //Se crea la lista de cortes del indicador
        List<DimensionalCut> dimensionalCutsA1_2 = new ArrayList<DimensionalCut>();
        dimensionalCutsA1_2.add(dimensionalcut1A1_2);
        dimensionalCutsA1_2.add(dimensionalcut2A1_2);
        dimensionalCutsA1_2.add(dimensionalcut3A1_2);
        dimensionalCutsA1_2.add(dimensionalcut4A1_2);
        dimensionalCutsA1_2.add(dimensionalcut5A1_2);
        dimensionalCutsA1_2.add(dimensionalcut6A1_2);
        dimensionalCutsA1_2.add(dimensionalcut7A1_2);
        dimensionalCutsA1_2.add(dimensionalcut8A1_2);
        dimensionalCutsA1_2.add(dimensionalcut9A1_2);
        dimensionalCutsA1_2.add(dimensionalcut10A1_2);
        dimensionalCutsA1_2.add(dimensionalcut11A1_2);
        dimensionalCutsA1_2.add(dimensionalcut12A1_2);
        dimensionalCutsA1_2.add(dimensionalcut13A1_2);
        dimensionalCutsA1_2.add(dimensionalcut14A1_2);
        dimensionalCutsA1_2.add(dimensionalcut15A1_2);
        dimensionalCutsA1_2.add(dimensionalcut16A1_2);


        //Populate DimensionalCut-DimensionalMember

        //TOTAL_PRODCUTOS 1, TOTAL_SISTEMAS_INFORMACION 1
        DimensionalCutMember dcm1A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm1A1_2.setDimensionMember(dimensionmember1Productos);
        dcm1A1_2.setDimensionalCut(dimensionalcut1A1_2);
        delegate.createDimensionalCutMember(dcm1A1_2);

        DimensionalCutMember dcm2A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm2A1_2.setDimensionMember(dimensionmember1Sistemas);
        dcm2A1_2.setDimensionalCut(dimensionalcut1A1_2);
        delegate.createDimensionalCutMember(dcm2A1_2);

        //TOTAL_PRODUCTOS 1, ERP 2

        DimensionalCutMember dcm3A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm3A1_2.setDimensionMember(dimensionmember1Productos);
        dcm3A1_2.setDimensionalCut(dimensionalcut2A1_2);
        delegate.createDimensionalCutMember(dcm3A1_2);

        DimensionalCutMember dcm4A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm4A1_2.setDimensionMember(dimensionmember2Sistemas);
        dcm4A1_2.setDimensionalCut(dimensionalcut2A1_2);
        delegate.createDimensionalCutMember(dcm4A1_2);

        //TOTAL_PRODUCTOS 1, CRM 3

        DimensionalCutMember dcm5A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm5A1_2.setDimensionMember(dimensionmember1Productos);
        dcm5A1_2.setDimensionalCut(dimensionalcut3A1_2);
        delegate.createDimensionalCutMember(dcm5A1_2);

        DimensionalCutMember dcm6A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm6A1_2.setDimensionMember(dimensionmember3Sistemas);
        dcm6A1_2.setDimensionalCut(dimensionalcut3A1_2);
        delegate.createDimensionalCutMember(dcm6A1_2);


        //TOTAL_PRODUCTOS 1, CONTROL_DE_PISO 4

        DimensionalCutMember dcm7A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm7A1_2.setDimensionMember(dimensionmember1Productos);
        dcm7A1_2.setDimensionalCut(dimensionalcut4A1_2);
        delegate.createDimensionalCutMember(dcm7A1_2);

        DimensionalCutMember dcm8A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm8A1_2.setDimensionMember(dimensionmember4Sistemas);
        dcm8A1_2.setDimensionalCut(dimensionalcut4A1_2);
        delegate.createDimensionalCutMember(dcm8A1_2);

        //-----------------------------------------------------------------------------------------------------------------

        //Cien Nectar 2, TOTAL_SISTEMAS_INFORMACION 1

        DimensionalCutMember dcm9A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm9A1_2.setDimensionMember(dimensionmember2Productos);
        dcm9A1_2.setDimensionalCut(dimensionalcut5A1_2);
        delegate.createDimensionalCutMember(dcm9A1_2);


        DimensionalCutMember dcm10A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm10A1_2.setDimensionMember(dimensionmember1Sistemas);
        dcm10A1_2.setDimensionalCut(dimensionalcut5A1_2);
        delegate.createDimensionalCutMember(dcm10A1_2);


        //Cien Nectar 2, ERP 2

        DimensionalCutMember dcm11A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm11A1_2.setDimensionMember(dimensionmember2Productos);
        dcm11A1_2.setDimensionalCut(dimensionalcut6A1_2);
        delegate.createDimensionalCutMember(dcm11A1_2);

        DimensionalCutMember dcm12A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm12A1_2.setDimensionMember(dimensionmember2Sistemas);
        dcm12A1_2.setDimensionalCut(dimensionalcut6A1_2);
        delegate.createDimensionalCutMember(dcm12A1_2);


        //Cien Nectar 2, CRM 3

        DimensionalCutMember dcm13A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm13A1_2.setDimensionMember(dimensionmember2Productos);
        dcm13A1_2.setDimensionalCut(dimensionalcut7A1_2);
        delegate.createDimensionalCutMember(dcm13A1_2);

        DimensionalCutMember dcm14A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm14A1_2.setDimensionMember(dimensionmember3Sistemas);
        dcm14A1_2.setDimensionalCut(dimensionalcut7A1_2);
        delegate.createDimensionalCutMember(dcm14A1_2);


        //Cien Nectar 2, CONTROL_DE_PISO 4

        DimensionalCutMember dcm15A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm15A1_2.setDimensionMember(dimensionmember2Productos);
        dcm15A1_2.setDimensionalCut(dimensionalcut8A1_2);
        delegate.createDimensionalCutMember(dcm15A1_2);

        DimensionalCutMember dcm16A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm16A1_2.setDimensionMember(dimensionmember4Sistemas);
        dcm16A1_2.setDimensionalCut(dimensionalcut8A1_2);
        delegate.createDimensionalCutMember(dcm16A1_2);

        //-----------------------------------------------------------------------------

        //Nectar Cero 3, TOTAL_SISTEMAS_INFORMACION 1

        DimensionalCutMember dcm17A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm17A1_2.setDimensionMember(dimensionmember3Productos);
        dcm17A1_2.setDimensionalCut(dimensionalcut9A1_2);
        delegate.createDimensionalCutMember(dcm17A1_2);

        DimensionalCutMember dcm18A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm18A1_2.setDimensionMember(dimensionmember1Sistemas);
        dcm18A1_2.setDimensionalCut(dimensionalcut9A1_2);
        delegate.createDimensionalCutMember(dcm18A1_2);

        //Nectar Cero 3, ERP 2

        DimensionalCutMember dcm19A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm19A1_2.setDimensionMember(dimensionmember3Productos);
        dcm19A1_2.setDimensionalCut(dimensionalcut10A1_2);
        delegate.createDimensionalCutMember(dcm19A1_2);

        DimensionalCutMember dcm20A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm20A1_2.setDimensionMember(dimensionmember2Sistemas);
        dcm20A1_2.setDimensionalCut(dimensionalcut10A1_2);
        delegate.createDimensionalCutMember(dcm20A1_2);


        //Nectar Cero 3, CRM 3

        DimensionalCutMember dcm21A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm21A1_2.setDimensionMember(dimensionmember3Productos);
        dcm21A1_2.setDimensionalCut(dimensionalcut11A1_2);
        delegate.createDimensionalCutMember(dcm21A1_2);

        DimensionalCutMember dcm22A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm22A1_2.setDimensionMember(dimensionmember3Sistemas);
        dcm22A1_2.setDimensionalCut(dimensionalcut11A1_2);
        delegate.createDimensionalCutMember(dcm22A1_2);

        //Nectar Cero 3, CONTROL_DE_PISO 4

        DimensionalCutMember dcm23A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm23A1_2.setDimensionMember(dimensionmember3Productos);
        dcm23A1_2.setDimensionalCut(dimensionalcut12A1_2);
        delegate.createDimensionalCutMember(dcm23A1_2);

        DimensionalCutMember dcm24A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm24A1_2.setDimensionMember(dimensionmember4Sistemas);
        dcm24A1_2.setDimensionalCut(dimensionalcut12A1_2);
        delegate.createDimensionalCutMember(dcm24A1_2);




        //Nectarin 4, TOTAL_SISTEMAS_INFORMACION 1

        DimensionalCutMember dcm25A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm25A1_2.setDimensionMember(dimensionmember4Productos);
        dcm25A1_2.setDimensionalCut(dimensionalcut13A1_2);
        delegate.createDimensionalCutMember(dcm25A1_2);

        DimensionalCutMember dcm26A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm26A1_2.setDimensionMember(dimensionmember1Sistemas);
        dcm26A1_2.setDimensionalCut(dimensionalcut13A1_2);
        delegate.createDimensionalCutMember(dcm26A1_2);

        //Nectarin 4, ERP 2

        DimensionalCutMember dcm27A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm27A1_2.setDimensionMember(dimensionmember4Productos);
        dcm27A1_2.setDimensionalCut(dimensionalcut14A1_2);
        delegate.createDimensionalCutMember(dcm27A1_2);

        DimensionalCutMember dcm28A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm28A1_2.setDimensionMember(dimensionmember2Sistemas);
        dcm28A1_2.setDimensionalCut(dimensionalcut14A1_2);
        delegate.createDimensionalCutMember(dcm28A1_2);

        //Nectarin 4, CRM 3

        DimensionalCutMember dcm29A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm29A1_2.setDimensionMember(dimensionmember4Productos);
        dcm29A1_2.setDimensionalCut(dimensionalcut15A1_2);
        delegate.createDimensionalCutMember(dcm29A1_2);

        DimensionalCutMember dcm30A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm30A1_2.setDimensionMember(dimensionmember3Sistemas);
        dcm30A1_2.setDimensionalCut(dimensionalcut15A1_2);
        delegate.createDimensionalCutMember(dcm30A1_2);

        //Nectarin 4, CONTROL_DE_PISO 4

        DimensionalCutMember dcm31A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm31A1_2.setDimensionMember(dimensionmember4Productos);
        dcm31A1_2.setDimensionalCut(dimensionalcut16A1_2);
        delegate.createDimensionalCutMember(dcm31A1_2);

        DimensionalCutMember dcm32A1_2 = (DimensionalCutMember) Factory.getBean("DimensionalCutMember");
        dcm32A1_2.setDimensionMember(dimensionmember4Sistemas);
        dcm32A1_2.setDimensionalCut(dimensionalcut16A1_2);
        delegate.createDimensionalCutMember(dcm32A1_2);



        //Se METEN LOS DATOS AL INDICADOR
        //SE CREAN las matrices de datos
        Double realValuesA1_2[][] = {{70.0D, 80.0D, 65.0D, 65.0D, 70.0D, 80.0D, 65.0D, 65.0D, 70.0D, 80.0D, 65.0D, 65.0D, 70.0D, 80.0D, 65.0D, 65.0D},
            {75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D},
            {78.0D, 82.0D, 80.0D, 72.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D},
            {74.0D, 80.0D, 76.0D, 66.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D},
            {71.0D, 85.0D, 65.0D, 63.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D},
            {76.0D, 78.0D, 74.0D, 76.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D}
        };


        Double metaValuesA1_2[][] = {{70.0D, 80.0D, 65.0D, 65.0D, 70.0D, 80.0D, 65.0D, 65.0D, 70.0D, 80.0D, 65.0D, 65.0D, 70.0D, 80.0D, 65.0D, 65.0D},
            {75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D},
            {78.0D, 82.0D, 80.0D, 72.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D},
            {74.0D, 80.0D, 76.0D, 66.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D},
            {71.0D, 85.0D, 65.0D, 63.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D},
            {76.0D, 78.0D, 74.0D, 76.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D, 75.0D, 70.0D, 80.0D, 75.0D}
        };

        //Se crean las FECHAS
        
        List<Date> datesA1_2 = ScoreCardUtils.generateDatesRange(ScoreCardUtils.generateDate(1, 1, 2011), ScoreCardUtils.generateDate(1, 6, 2011), pointerA1_2);


        for (int i = 0; i < datesA1_2.size(); i++) {
            for (int j = 0; j < dimensionalCutsA1_2.size(); j++) {

                //Valor Real
                ComparatorDimensionalCut cdcRealA1_2 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcRealA1_2.setComparator(comparatorRA1_2);
                cdcRealA1_2.setDimensionalCut(dimensionalCutsA1_2.get(j));
                cdcRealA1_2.setRegisterDate(datesA1_2.get(i));
                cdcRealA1_2.setRegister(realValuesA1_2[i][j]);
                delegate.createComparatorDimensionalCut(cdcRealA1_2);

                //Valor Meta
                ComparatorDimensionalCut cdcMetaA1_2 = (ComparatorDimensionalCut) Factory.getBean("ComparatorDimensionalCut");
                cdcMetaA1_2.setComparator(comparatorMA1_2);
                cdcMetaA1_2.setDimensionalCut(dimensionalCutsA1_2.get(j));
                cdcMetaA1_2.setRegisterDate(datesA1_2.get(i));
                cdcMetaA1_2.setRegister(metaValuesA1_2[i][j]);
                delegate.createComparatorDimensionalCut(cdcMetaA1_2);

            }
        }
        //INDICADORES
        //---------------------------FIN INDICADOR A1.2--------------------------------------------------------------------------------------






        //OBJETIVOS
        //-----------------------------------------SE CREA EL OBJETIVO F4------------------------------------------------------------------
        //Create Objetive Scorecard
        Objective objectiveScorecardF4 = (Objective) Factory.getBean("Objective");
        objectiveScorecardF4.setName("F4. Diversificar el negocio");
        objectiveScorecardF4.setDescription("Diseñar un portafolio de productos y servicios que responda a las necesidades integrales de nuestros Clientes, buscando consolidar los productos actuales y posicionar los nuevos productos.");
        objectiveScorecardF4.setResponsable("Jorge Villagrán");
        delegate.createObjective(objectiveScorecardF4);

        //-----------------------------------------FIN EL OBJETIVO F4------------------------------------------------------------------

        //-----------------------------------------SE CREA EL OBJETIVO C1------------------------------------------------------------------
        //Create Objetive Scorecard
        Objective objectiveScorecardC1 = (Objective) Factory.getBean("Objective");
        objectiveScorecardC1.setName("C1. Disponibilidad de producto");
        objectiveScorecardC1.setDescription("Contar con un inventario de producto que le asegure al Cliente que puede adquirir nuestros productos en el momento que lo requiera.");
        objectiveScorecardC1.setResponsable("Sergio Cruz");
        delegate.createObjective(objectiveScorecardC1);

        //-----------------------------------------FIN EL OBJETIVO C1------------------------------------------------------------------


        //-----------------------------------------SE CREA EL OBJETIVO P1------------------------------------------------------------------
        //Create Objetive Scorecard
        Objective objectiveScorecardP1 = (Objective) Factory.getBean("Objective");
        objectiveScorecardP1.setName("P1. Distribuir el producto en tiempo y forma");
        objectiveScorecardP1.setDescription("Hacer llegar nuestros productos a nuestros Clientes a través de estrategias de distribución apropiadas que garanticen una entrega oportuna y adecuada.");
        objectiveScorecardP1.setResponsable("Sergio Cruz");
        delegate.createObjective(objectiveScorecardP1);

        //-----------------------------------------FIN EL OBJETIVO P1------------------------------------------------------------------

        //-----------------------------------------SE CREA EL OBJETIVO A1------------------------------------------------------------------
        //Create Objetive Scorecard
        Objective objectiveScorecardA1 = (Objective) Factory.getBean("Objective");
        objectiveScorecardA1.setName("A1. Utilizar efectivamente los sistemas de información");
        objectiveScorecardA1.setDescription("Aprovechar los sistemas de información existentes dentro de la organización de tal forma que asegure el uso y generación de información confiable y oportuna.");
        objectiveScorecardA1.setResponsable("Federico Sánchez");
        delegate.createObjective(objectiveScorecardA1);

        //-----------------------------------------FIN EL OBJETIVO A1------------------------------------------------------------------

        //PERSPECTIVAS!!!!!
        //-----------------------------------------SE CREA LA PERSPECTIVA DE FINANZAS--------------------------------------------
        //Create Perspective Scorecard
        Perspective perspectiveScorecardFinance = (Perspective) Factory.getBean("Perspective");
        perspectiveScorecardFinance.setName("Perspectiva de Finanzas");
        perspectiveScorecardFinance.setDescription("Perspectiva que incluye todos los objetivos necesarios para generar oferta de valor para los socios");
        perspectiveScorecardFinance.setResponsable("SMO Néctares del Sureste");
        delegate.createPerspective(perspectiveScorecardFinance);

        //-----------------------------------------FIN PERSPECTIVA DE FINANZAS--------------------------------------------------

        //-----------------------------------------SE CREA LA PERSPECTIVA DE CLIENTES--------------------------------------------
        //Create Perspective Scorecard
        Perspective perspectiveScorecardClients = (Perspective) Factory.getBean("Perspective");
        perspectiveScorecardClients.setName("Perspectiva de Clientes");
        perspectiveScorecardClients.setDescription("Perspectiva que incluye todos los objetivos necesarios para ofrecer un mejor servicio y producto a nuestros clientes");
        perspectiveScorecardClients.setResponsable("SMO Néctares del Sureste");
        delegate.createPerspective(perspectiveScorecardClients);
        //-----------------------------------------FIN PERSPECTIVA DE CLIENTES--------------------------------------------


        //-----------------------------------------SE CREA LA PERSPECTIVA DE PROCESOS--------------------------------------------
        //Create Perspective Scorecard
        Perspective perspectiveScorecardProcess = (Perspective) Factory.getBean("Perspective");
        perspectiveScorecardProcess.setName("Perspectiva de Procesos");
        perspectiveScorecardProcess.setDescription("Perspectiva que incluye todos los objetivos para mejorar los procesos de Néctares del Sureste");
        perspectiveScorecardProcess.setResponsable("SMO Néctares del Sureste");
        delegate.createPerspective(perspectiveScorecardProcess);
        //-----------------------------------------------FIN PERSPECTIVA DE PROCESOS--------------------------------------------

        //-----------------------------------------SE CREA LA PERSPECTIVA DE APRENDIZAJE Y CRECIMIENTO--------------------------------------------
        //Create Perspective Scorecard
        Perspective perspectiveScorecardLearning = (Perspective) Factory.getBean("Perspective");
        perspectiveScorecardLearning.setName("Perspectiva de Aprendizaje y Crecimiento");
        perspectiveScorecardLearning.setDescription("Perspectiva que incluye todos los objetivos para la mejora de la cultura en Néctares del Sureste");
        perspectiveScorecardLearning.setResponsable("SMO Néctares del Sureste");
        delegate.createPerspective(perspectiveScorecardLearning);
        //-----------------------------------------------FIN PERSPECTIVA DE APRENDIZAJE Y CRECIMIENTO--------------------------------------------



        //-----------------------------------------SE CREA EL MAPA DE NECTARES--------------------------------------------
        //Create Perspective Scorecard
        //Create Map Scorecard
        Map mapScorecard = (Map) Factory.getBean("Map");
        mapScorecard.setName("Mapa de Dirección General");
        mapScorecard.setDescription("Mapa de Balanced ScoreCard de la Dirección General de Néctares del Sureste");
        mapScorecard.setResponsable("SMO Néctares del Sureste");
        delegate.createMap(mapScorecard);

        //-----------------------------------------FIN DE MAPA DE NECTARES---------------------------------------------------



        //---------------------------------------------------RELACIONES DE SCORECARDS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        //MAPA CON SUS PERSPECTIVAS
        ScoreCardRelation scoreCardRelationM_F = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationM_F.setScoreCard(mapScorecard);
        scoreCardRelationM_F.setOtherScoreCard(perspectiveScorecardFinance);
        scoreCardRelationM_F.setPercentFactor(.25D);
        delegate.createScoreCardRelation(scoreCardRelationM_F);

        ScoreCardRelation scoreCardRelationM_C = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationM_C.setScoreCard(mapScorecard);
        scoreCardRelationM_C.setOtherScoreCard(perspectiveScorecardClients);
        scoreCardRelationM_C.setPercentFactor(.25D);
        delegate.createScoreCardRelation(scoreCardRelationM_C);

        ScoreCardRelation scoreCardRelationM_P = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationM_P.setScoreCard(mapScorecard);
        scoreCardRelationM_P.setOtherScoreCard(perspectiveScorecardProcess);
        scoreCardRelationM_P.setPercentFactor(.25D);
        delegate.createScoreCardRelation(scoreCardRelationM_P);

        ScoreCardRelation scoreCardRelationM_L = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationM_L.setScoreCard(mapScorecard);
        scoreCardRelationM_L.setOtherScoreCard(perspectiveScorecardLearning);
        scoreCardRelationM_L.setPercentFactor(.25D);
        delegate.createScoreCardRelation(scoreCardRelationM_L);

        // PERSPECTIVA DE FINANZAS CON SUS OBJETIVOS

        ScoreCardRelation scoreCardRelationF_F3 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationF_F3.setScoreCard(perspectiveScorecardFinance);
        scoreCardRelationF_F3.setOtherScoreCard(objectiveScorecardF3);
        scoreCardRelationF_F3.setPercentFactor(.5D);
        delegate.createScoreCardRelation(scoreCardRelationF_F3);


        ScoreCardRelation scoreCardRelationF_F4 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationF_F4.setScoreCard(perspectiveScorecardFinance);
        scoreCardRelationF_F4.setOtherScoreCard(objectiveScorecardF4);
        scoreCardRelationF_F4.setPercentFactor(.5D);
        delegate.createScoreCardRelation(scoreCardRelationF_F4);

        // PERSPECTIVA DE CLIENTES CON SUS OBJETIVOS

        ScoreCardRelation scoreCardRelationC_C1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationC_C1.setScoreCard(perspectiveScorecardClients);
        scoreCardRelationC_C1.setOtherScoreCard(objectiveScorecardC1);
        scoreCardRelationC_C1.setPercentFactor(1D);
        delegate.createScoreCardRelation(scoreCardRelationC_C1);

        // PERSPECTIVA DE PROCESOS CON SUS OBJETIVOS

        ScoreCardRelation scoreCardRelationP_P1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationP_P1.setScoreCard(perspectiveScorecardProcess);
        scoreCardRelationP_P1.setOtherScoreCard(objectiveScorecardP1);
        scoreCardRelationP_P1.setPercentFactor(1D);
        delegate.createScoreCardRelation(scoreCardRelationP_P1);

        // PERSPECTIVA DE APRENDIZAJE CON SUS OBJETIVOS

        ScoreCardRelation scoreCardRelationL_A1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationL_A1.setScoreCard(perspectiveScorecardLearning);
        scoreCardRelationL_A1.setOtherScoreCard(objectiveScorecardA1);
        scoreCardRelationL_A1.setPercentFactor(1D);
        delegate.createScoreCardRelation(scoreCardRelationL_A1);

        //OBJETIVO F3 CON SUS INDICADORES
        ScoreCardRelation scoreCardRelationF3_F3_1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationF3_F3_1.setScoreCard(objectiveScorecardF3);
        scoreCardRelationF3_F3_1.setOtherScoreCard(pointerF3_1);
        scoreCardRelationF3_F3_1.setPercentFactor(.7D);
        delegate.createScoreCardRelation(scoreCardRelationF3_F3_1);


        ScoreCardRelation scoreCardRelationF3_F3_2 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationF3_F3_2.setScoreCard(objectiveScorecardF3);
        scoreCardRelationF3_F3_2.setOtherScoreCard(pointerF3_2);
        scoreCardRelationF3_F3_2.setPercentFactor(.3D);
        delegate.createScoreCardRelation(scoreCardRelationF3_F3_2);

        //OBJETVIO F4 CON SUS INDICADORES
        ScoreCardRelation scoreCardRelationF4_F4_1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationF4_F4_1.setScoreCard(objectiveScorecardF4);
        scoreCardRelationF4_F4_1.setOtherScoreCard(pointerF4_1);
        scoreCardRelationF4_F4_1.setPercentFactor(1D);
        delegate.createScoreCardRelation(scoreCardRelationF4_F4_1);


        //OBJETVIO C1 CON SUS INDICADORES

        ScoreCardRelation scoreCardRelationC1_C1_1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationC1_C1_1.setScoreCard(objectiveScorecardC1);
        scoreCardRelationC1_C1_1.setOtherScoreCard(pointerC1_1);
        scoreCardRelationC1_C1_1.setPercentFactor(.5D);
        delegate.createScoreCardRelation(scoreCardRelationC1_C1_1);

        ScoreCardRelation scoreCardRelationC1_C1_2 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationC1_C1_2.setScoreCard(objectiveScorecardC1);
        scoreCardRelationC1_C1_2.setOtherScoreCard(pointerC1_2);
        scoreCardRelationC1_C1_2.setPercentFactor(.5D);
        delegate.createScoreCardRelation(scoreCardRelationC1_C1_2);

        //OBJETVIO P1 CON SUS INDICADORES y PROYECTO

        ScoreCardRelation scoreCardRelationP1_P1_1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationP1_P1_1.setScoreCard(objectiveScorecardP1);
        scoreCardRelationP1_P1_1.setOtherScoreCard(pointerP1_1);
        scoreCardRelationP1_P1_1.setPercentFactor(.7D);
        delegate.createScoreCardRelation(scoreCardRelationP1_P1_1);

        ScoreCardRelation scoreCardRelationP1_Proy1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationP1_Proy1.setScoreCard(objectiveScorecardP1);
        scoreCardRelationP1_Proy1.setOtherScoreCard(projectP1);
        scoreCardRelationP1_Proy1.setPercentFactor(.3D);
        delegate.createScoreCardRelation(scoreCardRelationP1_Proy1);


        //OBJETVIO A1 CON SUS INDICADORES

        ScoreCardRelation scoreCardRelationA1_A1_1 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationA1_A1_1.setScoreCard(objectiveScorecardA1);
        scoreCardRelationA1_A1_1.setOtherScoreCard(pointerA1_1);
        scoreCardRelationA1_A1_1.setPercentFactor(.5D);
        delegate.createScoreCardRelation(scoreCardRelationA1_A1_1);

        //OBJETVIO A1 CON SUS INDICADORES

        ScoreCardRelation scoreCardRelationA1_A1_2 = (ScoreCardRelation) Factory.getBean("ScoreCardRelation");
        scoreCardRelationA1_A1_2.setScoreCard(objectiveScorecardA1);
        scoreCardRelationA1_A1_2.setOtherScoreCard(pointerA1_2);
        scoreCardRelationA1_A1_2.setPercentFactor(.5D);
        delegate.createScoreCardRelation(scoreCardRelationA1_A1_2);

        //Create a Designer
        Person personDesigner = (Person) Factory.getBean("Person");
        personDesigner.setName("Usuario Diseñador");
        personDesigner.setEmail("malp17@gmail.com");
        personDesigner.setUsername("designer");
        personDesigner.setPassword("designer");
        personDesigner.setProfile(Person.Profile.DESIGNER);
        delegate.createPerson(personDesigner);


        Person person = (Person) Factory.getBean("Person");
        person.setName("Usuario Demo");
        person.setEmail("malp17@gmail.com");
        person.setUsername("demouser");
        person.setPassword("demouser");
        person.setProfile(Person.Profile.NORMAL_USER);
        delegate.createPerson(person);

        
        
        //Se crea el dominio designer
        ScoreDomain scoreDomainDesigner = (ScoreDomain) Factory.getBean("ScoreDomain");
        scoreDomainDesigner.setName("Dominio de Administradores");
        delegate.createScoreDomain(scoreDomainDesigner);

        //Se crea el dominio
        ScoreDomain scoreDomain = (ScoreDomain) Factory.getBean("ScoreDomain");
        scoreDomain.setName("Dominio Nectares del Sureste");
        delegate.createScoreDomain(scoreDomain);

    }
}
